'use strict';
const port = 9528; // 开发环境 前台端口
const backendPort = 9500;//开发环境 后台接口
const fileSysPort = 8018;//开发环境 文件系统


const path = require("path");

function resolve(dir) {
    return path.join(__dirname, dir);
}

module.exports = {
    //设置为true 更方便错误定位
    productionSourceMap: false,
    runtimeCompiler: true,
    chainWebpack: config => {
        config.resolve.alias
            .set("@", resolve("src"))
            .set("assets@", resolve("src/assets"))
            .set("components@", resolve("src/components"))
            .set("plugins@", resolve("src/plugins"))
            .set("public@", resolve("public"));
    },
    devServer: {
        port: port,
        open: true,
        overlay: {
            warnings: false,
            errors: true
        },
        proxy: {
            '/api': {
                target: `http://127.0.0.1:${backendPort}`,
                changeOrigin: true,
                secure: true,
                pathRewrite: {
                    "^/api": ""
                }
            },
            '/file': {
                target: `http://127.0.0.1:${fileSysPort}`,
                changeOrigin: true,
                secure: true,
                pathRewrite: {
                    "^/file": ""
                }
            },
            '/github': {
                target: 'https://github.com',
                changeOrigin: true,
                pathRewrite: {
                    '^/github': '/'
                }
            }
        }
    },

    publicPath: './'
};